/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View;

import Controler.Controler;
import ObserveTools.MessagePlateau;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Insets;
import java.util.Observable;
import java.util.Observer;
import javax.swing.JTextArea;

/**
 * Affiche la couleur du joueur qui dois jouer
 * @author goum
 */
public class TourView extends JTextArea implements Observer {

    String sentence;
    protected Controler controler;

    public TourView(String sentence) {
        this.sentence = sentence;
    }

    public TourView(Controler controler) {
        Insets inset = new Insets(65, 50, 20, 0);
        Font font = new Font("Calibri", Font.BOLD, 25);
        this.setForeground(Color.white);
        this.setPreferredSize(new Dimension(250, 400));
        this.setFont(font);
        this.setBackground(Color.LIGHT_GRAY);
        this.controler = controler;
        this.setMargin(inset);
        this.sentence = "Tour\nBlanc";
        this.controler.getPlateau().addObserver(this);
        this.setText(this.sentence);
    }

    public TourView(String sentence, Controler controler) {
        this.sentence = sentence;
        this.controler = controler;
    }

    public Controler getControler() {
        return controler;
    }

    public void setControler(Controler controler) {
        this.controler = controler;
    }

    public String getSentence() {
        return sentence;
    }

    public void setSentence(String sentence) {
        this.sentence = sentence;
    }

    /**
     * Met a jour l'information de tour en cour
     */
    public void update(Observable o, Object o1) {
        MessagePlateau message = (MessagePlateau) o1;
        if (message.getErreur() == 9) {
            this.setForeground(Color.white);
            this.sentence = "Tour\nBlanc";
            this.setText(this.sentence);
        } else if (message.getErreur() == 10) {
            this.setForeground(Color.BLACK);
            this.sentence = "Tour\nNoir";
            this.setText(this.sentence);
        }
    }
}
